package com.boot2.core.web.websocket;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zhangweilin
 * @Description: xxxxx
 * @date 2020/12/28
 */
public abstract class WebSocketSessionStatus implements WebSocketSessionListener {

    private Map<String, Integer> onlineMap = new ConcurrentHashMap<>();

    @Override
    public void online(String userName) {
        onlineMap.put(userName, 1);
    }

    @Override
    public void offline(String userName) {
        onlineMap.remove(userName);
    }

    public Boolean isOnline(String userName) {
        Integer status = onlineMap.get(userName);
        if (null == status) {
            return false;
        }else{
            return true;
        }
    }
}
